package cn.buk.tms.eotms.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import jakarta.persistence.*;
import java.util.Date;

/**
 * 客户：企业客户、散客、同行等从我处购买产品或服务的个人或企业。
 * @author yfdai
 */
@Entity
@Table(name="t102",	uniqueConstraints=@UniqueConstraint(name="uk_customer_enterprise",	columnNames={"enterprise_id", "customer_enterprise_id"} ))
public class Customer {

    /**
     * 企业散客
     */
    public static final int ENT_INDIVIDUAL = 0;

	/**
	 * 散客
	 */
    public static final int INDIVIDUAL = 0;

	/**
	 * 月结企业客户
	 */
	public static final int ENT_CORPORATION = 1;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int id;

	/**
	 * 所属企业的企业ID
	 */
	@Column(name = "enterprise_id", updatable = false)
	private int enterpriseId;

	/**
	 * 客户代码（系统生成）, 对应相对应的t101中的用户名的enterpriseId
	 * 此客户在系统中对应的enterpriseId
	 * 此数据库类型是为了以前为了兼容导致的，以后可以改掉
	 * vipCode 放弃不用
	 */
	@Deprecated
	@Column(name = "vipCode", length = 10, updatable = false)
	private  String vipCode;

	/**
	 * 该客户对应的enterpriseId,
	 * 可以为null, 但不允许为0
	 */
	@Column(name = "customer_enterprise_id")
	private Integer customerEnterpriseId;

	/**
	 * 企业名称
	 */
	@Column(length = 50)
	private String vipName;

	/**
	 * 企业全称
	 */
	@Column(length = 50)
	private String fullName;

	/**
	 * 客户编号(用户自定义，用于显示）
	 */
	@Column(name = "customer_code", length = 30)
	private String customerCode;


	/**
	 * 与t101中的username相同, 冗余
	 */
	private String username;

	/**
	 * 合同联系人
	 */
	@Column(name = "contract_linkman")
	private String contractLinkman;

	/**
	 * 合同联系人的联系电话
	 */
	@Column(name = "contract_link_phone")
	private String contractLinkPhone;

	/**
	 * 企业差旅负责人（审核人）(账单）
	 */
	@Column(length = 30)
	private String linkman;

	/**
	 * 联系电话
	 */
	@Column(length = 20)
	private String phone;

	private String email;

	private String mobile;

	@Column(length = 20)
	private String fax;

	/**
	 * 邮编
	 */
	@Column(name = "post_code")
	private String postCode;

	/**
	 * 账单邮寄地址
	 */
	@Column(name = "vipaddr", length = 200)
	private String address;

	/**
	 * 是否需要审批出票
	 * 0/null-不需要
	 * 1-需要
	 */
	@Column(name = "approval_ticket")
	private Integer approvalTicket;


	/**
	 * 客户合作状态：
	 * null/1 - 启用
	 * 0 - 停用
	 */
	private Integer status = 1;

	/**
	 * 是否处于测试模式，测试模式的客户所有的订单全部人工处理
	 */
	@Column(name = "test_mode")
	private Integer testMode;

	/**
	 * 适用的服务费模板
	 */
	@Column(name = "template_code", length = 5)
	private String templateCode;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", insertable = false, updatable = false)
	private Date createTime;

	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_update", insertable = false)
	private Date lastUpdate;

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the vipName
	 */
	public String getVipName() {
		return vipName;
	}

	/**
	 * @param vipName the vipName to set
	 */
	public void setVipName(String vipName) {
		this.vipName = vipName;
	}

	/**
	 * @return the fullName
	 */
	public String getFullName() {
		return fullName;
	}

	/**
	 * @param fullName the fullName to set
	 */
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @param phone the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * @return the fax
	 */
	public String getFax() {
		return fax;
	}

	/**
	 * @param fax the fax to set
	 */
	public void setFax(String fax) {
		this.fax = fax;
	}

	/**
	 * @return the enterpriseId
	 */
	public int getEnterpriseId() {
		return enterpriseId;
	}

	/**
	 * @param enterpriseId the enterpriseId to set
	 */
	public void setEnterpriseId(int enterpriseId) {
		this.enterpriseId = enterpriseId;
	}

	public String getPostCode() {
		return postCode;
	}

	public void setPostCode(String postCode) {
		this.postCode = postCode;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getCustomerCode() {
		return customerCode;
	}

	public void setCustomerCode(String customerCode) {
		this.customerCode = customerCode == null ? null : customerCode.trim();
	}

	public String getContractLinkman() {
		return contractLinkman;
	}

	public void setContractLinkman(String contractLinkman) {
		this.contractLinkman = contractLinkman;
	}

	public String getContractLinkPhone() {
		return contractLinkPhone;
	}

	public void setContractLinkPhone(String contractLinkPhone) {
		this.contractLinkPhone = contractLinkPhone;
	}

	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getLastUpdate() {
		return lastUpdate;
	}

	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	public int getCustomerEnterpriseId() {
		return customerEnterpriseId == null ? 0: customerEnterpriseId;
	}

	public void setCustomerEnterpriseId(Integer customerEnterpriseId) {
		if (customerEnterpriseId != null && customerEnterpriseId != 0) {
			this.customerEnterpriseId = customerEnterpriseId;
		}
	}

	public int getStatus() {
		return status == null ? 1 : status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getApprovalTicket() {
		return approvalTicket;
	}

	public void setApprovalTicket(Integer approvalTicket) {
		this.approvalTicket = approvalTicket;
	}

	public String getTemplateCode() {
		return templateCode;
	}

	public void setTemplateCode(String templateCode) {
		this.templateCode = templateCode;
	}

	public int getTestMode() {
		return testMode == null ? 0 : testMode;
	}

	public void setTestMode(Integer testMode) {
		this.testMode = testMode;
	}
}